/*
 * @Author: fuhongliang-TSJ hongliang.fu@4d-bios.com
 * @Date: 2025-09-26 10:40:12
 * @LastEditTime: 2025-09-30 17:33:59
 * @LastEditors: fuhongliang-TSJ hongliang.fu@4d-bios.com
 * @Description: 
 * @FilePath: \lc_-esp32_-s3\main\lc\desktop_weather\desktop_weather_ui.c
 * 立创实战派ESP32-S3开发板
 * Copyright (c) 2025 by 4D Bios, All Rights Reserved. 
 */

#include <time.h>
#include <math.h>
#include "esp_log.h"
#include "sntp.h"
#include "desktop_weather.h"
#include "he_feng_weather.h"

static const char *TAG = "Desktop Weather UI";

LV_FONT_DECLARE(font_alipuhui20);
LV_FONT_DECLARE(font_qweather);
LV_FONT_DECLARE(font_led);
LV_FONT_DECLARE(font_awesome);
LV_IMG_DECLARE(image_taikong);

lv_obj_t *gif_taikong;
lv_obj_t *label_wifi_connect;
lv_obj_t *label_sntp;
lv_obj_t *label_weather;

lv_obj_t *label_date;
lv_obj_t *label_weather_icon;
lv_obj_t *obj_qair_level;
lv_obj_t *label_qair_level;
lv_obj_t *label_weather_temp;
lv_obj_t *label_weather_text;
lv_obj_t *label_time;
lv_obj_t *label_week;
lv_obj_t *label_sun;
lv_obj_t *label_out_door_temp;
lv_obj_t *label_out_door_humi;
lv_obj_t *label_in_door_temp;
lv_obj_t *label_in_door_humi;
lv_obj_t *label_wifi_icon;

extern char qwnow_text[32]; // 实时天气状态

extern time_t now;
extern struct tm timeinfo;

extern int temp_value, humi_value; // 室内实时温湿度值

extern qweather_data_t st_qweather_data; //和风天气数据

// 显示天气图标
void lv_qweather_icon_show(int now_icon)
{
    switch (now_icon)
    {
        case 100: lv_label_set_text(label_weather_icon, "\xEF\x84\x81"); strcpy(qwnow_text,"晴"); break;
        case 101: lv_label_set_text(label_weather_icon, "\xEF\x84\x82"); strcpy(qwnow_text, "多云"); break;
        case 102: lv_label_set_text(label_weather_icon, "\xEF\x84\x83"); strcpy(qwnow_text, "少云"); break;
        case 103: lv_label_set_text(label_weather_icon, "\xEF\x84\x84"); strcpy(qwnow_text, "晴间多云"); break;
        case 104: lv_label_set_text(label_weather_icon, "\xEF\x84\x85"); strcpy(qwnow_text, "阴"); break;
        case 150: lv_label_set_text(label_weather_icon, "\xEF\x84\x86"); strcpy(qwnow_text, "晴"); break;
        case 151: lv_label_set_text(label_weather_icon, "\xEF\x84\x87"); strcpy(qwnow_text, "多云"); break;
        case 152: lv_label_set_text(label_weather_icon, "\xEF\x84\x88"); strcpy(qwnow_text, "少云"); break;
        case 153: lv_label_set_text(label_weather_icon, "\xEF\x84\x89"); strcpy(qwnow_text, "晴间多云"); break;
        case 300: lv_label_set_text(label_weather_icon, "\xEF\x84\x8A"); strcpy(qwnow_text, "阵雨"); break;
        case 301: lv_label_set_text(label_weather_icon, "\xEF\x84\x8B"); strcpy(qwnow_text, "强阵雨"); break;
        case 302: lv_label_set_text(label_weather_icon, "\xEF\x84\x8C"); strcpy(qwnow_text, "雷阵雨"); break;
        case 303: lv_label_set_text(label_weather_icon, "\xEF\x84\x8D"); strcpy(qwnow_text, "强雷阵雨"); break;
        case 304: lv_label_set_text(label_weather_icon, "\xEF\x84\x8E"); strcpy(qwnow_text, "雷阵雨伴有冰雹"); break;
        case 305: lv_label_set_text(label_weather_icon, "\xEF\x84\x8F"); strcpy(qwnow_text, "小雨"); break;
        case 306: lv_label_set_text(label_weather_icon, "\xEF\x84\x90"); strcpy(qwnow_text, "中雨"); break;
        case 307: lv_label_set_text(label_weather_icon, "\xEF\x84\x91"); strcpy(qwnow_text, "大雨"); break;
        case 308: lv_label_set_text(label_weather_icon, "\xEF\x84\x92"); strcpy(qwnow_text, "极端降雨"); break;
        case 309: lv_label_set_text(label_weather_icon, "\xEF\x84\x93"); strcpy(qwnow_text, "毛毛雨"); break;
        case 310: lv_label_set_text(label_weather_icon, "\xEF\x84\x94"); strcpy(qwnow_text, "暴雨"); break;
        case 311: lv_label_set_text(label_weather_icon, "\xEF\x84\x95"); strcpy(qwnow_text, "大暴雨"); break;
        case 312: lv_label_set_text(label_weather_icon, "\xEF\x84\x96"); strcpy(qwnow_text, "特大暴雨"); break;
        case 313: lv_label_set_text(label_weather_icon, "\xEF\x84\x97"); strcpy(qwnow_text, "冻雨"); break;
        case 314: lv_label_set_text(label_weather_icon, "\xEF\x84\x98"); strcpy(qwnow_text, "小到中雨"); break;
        case 315: lv_label_set_text(label_weather_icon, "\xEF\x84\x99"); strcpy(qwnow_text, "中到大雨"); break;
        case 316: lv_label_set_text(label_weather_icon, "\xEF\x84\x9A"); strcpy(qwnow_text, "大到暴雨"); break;
        case 317: lv_label_set_text(label_weather_icon, "\xEF\x84\x9B"); strcpy(qwnow_text, "暴雨到大暴雨"); break;
        case 318: lv_label_set_text(label_weather_icon, "\xEF\x84\x9C"); strcpy(qwnow_text, "大暴雨到特大暴雨"); break;
        case 350: lv_label_set_text(label_weather_icon, "\xEF\x84\x9D"); strcpy(qwnow_text, "阵雨"); break;
        case 351: lv_label_set_text(label_weather_icon, "\xEF\x84\x9E"); strcpy(qwnow_text, "强阵雨"); break;
        case 399: lv_label_set_text(label_weather_icon, "\xEF\x84\x9F"); strcpy(qwnow_text, "雨"); break;
        case 400: lv_label_set_text(label_weather_icon, "\xEF\x84\xA0"); strcpy(qwnow_text, "小雪"); break;
        case 401: lv_label_set_text(label_weather_icon, "\xEF\x84\xA1"); strcpy(qwnow_text, "中雪"); break;
        case 402: lv_label_set_text(label_weather_icon, "\xEF\x84\xA2"); strcpy(qwnow_text, "大雪"); break;
        case 403: lv_label_set_text(label_weather_icon, "\xEF\x84\xA3"); strcpy(qwnow_text, "暴雪"); break;
        case 404: lv_label_set_text(label_weather_icon, "\xEF\x84\xA4"); strcpy(qwnow_text, "雨夹雪"); break;
        case 405: lv_label_set_text(label_weather_icon, "\xEF\x84\xA5"); strcpy(qwnow_text, "雨雪天气"); break;
        case 406: lv_label_set_text(label_weather_icon, "\xEF\x84\xA6"); strcpy(qwnow_text, "阵雨夹雪"); break;
        case 407: lv_label_set_text(label_weather_icon, "\xEF\x84\xA7"); strcpy(qwnow_text, "阵雪"); break;
        case 408: lv_label_set_text(label_weather_icon, "\xEF\x84\xA8"); strcpy(qwnow_text, "小到中雪"); break;
        case 409: lv_label_set_text(label_weather_icon, "\xEF\x84\xA9"); strcpy(qwnow_text, "中到大雪"); break;
        case 410: lv_label_set_text(label_weather_icon, "\xEF\x84\xAA"); strcpy(qwnow_text, "大到暴雪"); break;
        case 456: lv_label_set_text(label_weather_icon, "\xEF\x84\xAB"); strcpy(qwnow_text, "阵雨夹雪"); break;
        case 457: lv_label_set_text(label_weather_icon, "\xEF\x84\xAC"); strcpy(qwnow_text, "阵雪"); break;
        case 499: lv_label_set_text(label_weather_icon, "\xEF\x84\xAD"); strcpy(qwnow_text, "雪"); break;
        case 500: lv_label_set_text(label_weather_icon, "\xEF\x84\xAE"); strcpy(qwnow_text, "薄雾"); break;
        case 501: lv_label_set_text(label_weather_icon, "\xEF\x84\xAF"); strcpy(qwnow_text, "雾"); break;
        case 502: lv_label_set_text(label_weather_icon, "\xEF\x84\xB0"); strcpy(qwnow_text, "霾"); break;
        case 503: lv_label_set_text(label_weather_icon, "\xEF\x84\xB1"); strcpy(qwnow_text, "扬沙"); break;
        case 504: lv_label_set_text(label_weather_icon, "\xEF\x84\xB2"); strcpy(qwnow_text, "浮尘"); break;
        case 507: lv_label_set_text(label_weather_icon, "\xEF\x84\xB3"); strcpy(qwnow_text, "沙尘暴"); break;
        case 508: lv_label_set_text(label_weather_icon, "\xEF\x84\xB4"); strcpy(qwnow_text, "强沙尘暴"); break;
        case 509: lv_label_set_text(label_weather_icon, "\xEF\x84\xB5"); strcpy(qwnow_text, "浓雾"); break;
        case 510: lv_label_set_text(label_weather_icon, "\xEF\x84\xB6"); strcpy(qwnow_text, "强浓雾"); break;
        case 511: lv_label_set_text(label_weather_icon, "\xEF\x84\xB7"); strcpy(qwnow_text, "中度霾"); break;
        case 512: lv_label_set_text(label_weather_icon, "\xEF\x84\xB8"); strcpy(qwnow_text, "重度霾"); break;
        case 513: lv_label_set_text(label_weather_icon, "\xEF\x84\xB9"); strcpy(qwnow_text, "严重霾"); break;
        case 514: lv_label_set_text(label_weather_icon, "\xEF\x84\xBA"); strcpy(qwnow_text, "大雾"); break;
        case 515: lv_label_set_text(label_weather_icon, "\xEF\x84\xBB"); strcpy(qwnow_text, "特强浓雾"); break;
        case 900: lv_label_set_text(label_weather_icon, "\xEF\x85\x84"); strcpy(qwnow_text, "热"); break;
        case 901: lv_label_set_text(label_weather_icon, "\xEF\x85\x85"); strcpy(qwnow_text, "冷"); break;    
        
        default:
            printf("ICON_CODE:%d\n", now_icon);
            lv_label_set_text(label_weather_icon, "\xEF\x85\x86");
            strcpy(qwnow_text, "未知天气");
            break;
    }
}

// 显示空气质量
void lv_qair_level_show(int qanow_level)
{
    switch (qanow_level)
    {
        case 1: 
            lv_label_set_text(label_qair_level, "优"); 
            lv_obj_set_style_bg_color(obj_qair_level, lv_palette_main(LV_PALETTE_GREEN), 0); 
            lv_obj_set_style_text_color(label_qair_level, lv_color_hex(0xFFFFFF), 0);
            break;
        case 2: 
            lv_label_set_text(label_qair_level, "良"); 
            lv_obj_set_style_bg_color(obj_qair_level, lv_palette_main(LV_PALETTE_YELLOW), 0); 
            lv_obj_set_style_text_color(label_qair_level, lv_color_hex(0x000000), 0);
            break;
        case 3: 
            lv_label_set_text(label_qair_level, "轻");
            lv_obj_set_style_bg_color(obj_qair_level, lv_palette_main(LV_PALETTE_ORANGE), 0); 
            lv_obj_set_style_text_color(label_qair_level, lv_color_hex(0xFFFFFF), 0); 
            break;
        case 4: 
            lv_label_set_text(label_qair_level, "中"); 
            lv_obj_set_style_bg_color(obj_qair_level, lv_palette_main(LV_PALETTE_RED), 0); 
            lv_obj_set_style_text_color(label_qair_level, lv_color_hex(0xFFFFFF), 0);
            break; 
        case 5: 
            lv_label_set_text(label_qair_level, "重"); 
            lv_obj_set_style_bg_color(obj_qair_level, lv_palette_main(LV_PALETTE_PURPLE), 0); 
            lv_obj_set_style_text_color(label_qair_level, lv_color_hex(0xFFFFFF), 0);
            break;
        case 6: 
            lv_label_set_text(label_qair_level, "严"); 
            lv_obj_set_style_bg_color(obj_qair_level, lv_palette_main(LV_PALETTE_BROWN), 0); 
            lv_obj_set_style_text_color(label_qair_level, lv_color_hex(0xFFFFFF), 0);
            break;
        default: 
            lv_label_set_text(label_qair_level, "未"); 
            lv_obj_set_style_bg_color(obj_qair_level, lv_palette_main(LV_PALETTE_GREEN), 0); 
            lv_obj_set_style_text_color(label_qair_level, lv_color_hex(0xFFFFFF), 0);
            break;
    }
}

// 显示星期几
void lv_week_show(void)
{
    switch (timeinfo.tm_wday)
    {
        case 0: lv_label_set_text(label_week, "星期日"); break;
        case 1: lv_label_set_text(label_week, "星期一"); break;
        case 2: lv_label_set_text(label_week, "星期二"); break;
        case 3: lv_label_set_text(label_week, "星期三"); break;
        case 4: lv_label_set_text(label_week, "星期四"); break; 
        case 5: lv_label_set_text(label_week, "星期五"); break;
        case 6: lv_label_set_text(label_week, "星期六"); break;
        default: lv_label_set_text(label_week, "星期日"); break;
    }
}

// 桌面天气界面开始界面
void desktop_weather_gui_start(void)
{
    lvgl_port_lock(0);
    //黑色背景
    lv_obj_set_style_bg_color(lv_scr_act(), lv_color_hex(0x080808), 0);
    lv_obj_clear_flag(lv_scr_act(), LV_OBJ_FLAG_SCROLLABLE);

    //太空人GIF图片
    gif_taikong = lv_gif_create(lv_scr_act());
    lv_gif_set_src(gif_taikong, &image_taikong);
    lv_obj_align(gif_taikong, LV_ALIGN_TOP_MID, 0, 20);

    //配网连接wifi
    label_wifi_connect = lv_label_create(lv_scr_act());
    lv_obj_set_style_text_color(label_wifi_connect, lv_color_hex(0x888888), 0);
    lv_obj_set_style_text_font(label_wifi_connect, &font_alipuhui20, 0);
    lv_label_set_text(label_wifi_connect, "正在连接WiFi");
    lv_obj_align_to(label_wifi_connect, gif_taikong, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);

    //获取网络时间
    label_sntp = lv_label_create(lv_scr_act());
    lv_obj_set_style_text_color(label_sntp, lv_color_make(136, 136, 136), 0);
    lv_obj_set_style_text_font(label_sntp, &font_alipuhui20, 0);
    lv_label_set_text(label_sntp, "");
    lv_obj_align_to(label_sntp, label_wifi_connect, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);

    //获取天气信息
    label_weather = lv_label_create(lv_scr_act());
    lv_obj_set_style_text_color(label_weather, lv_color_hex(0x888888), 0);
    lv_obj_set_style_text_font(label_weather, &font_alipuhui20, 0);
    lv_label_set_text(label_weather, "");
    lv_obj_align_to(label_weather, label_sntp, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);

    lvgl_port_unlock();
}

// 桌面天气界面主界面
void desktop_weather_gui_main_page(void)
{
    lvgl_port_lock(0);

    // 清除页面显示
    lv_obj_clean(lv_scr_act());
    
    lv_obj_set_style_bg_color(lv_scr_act(), lv_color_hex(0x000000), 0);

    // 主页面
    lv_obj_t * obj_main_page = lv_obj_create(lv_scr_act());

    lv_obj_set_style_radius(obj_main_page, 10, 0);
    lv_obj_set_style_opa(obj_main_page, LV_OPA_COVER , 0);
    lv_obj_set_style_bg_color(obj_main_page, lv_color_hex(0x00BFFF), 0);
    lv_obj_set_style_border_width(obj_main_page, 0, 0);
    lv_obj_set_style_pad_all(obj_main_page, 10, 0);
    lv_obj_set_width(obj_main_page, 320);  // 设置宽
    lv_obj_set_height(obj_main_page, 240); // 设置高
    
    // 地址位置标签
    lv_obj_t *label_addr = lv_label_create(obj_main_page);
    lv_label_set_text(label_addr, "杭州市");
    lv_obj_set_style_text_font(label_addr, &font_alipuhui20, 0);
    lv_obj_align(label_addr, LV_ALIGN_TOP_LEFT, 0, 0);

    // 日期标签
    label_date = lv_label_create(obj_main_page);
    char str_date[20] = {0};
    get_date_str(str_date);
    lv_label_set_text(label_date, str_date);
    lv_obj_set_style_text_font(label_date, &font_alipuhui20, 0);
    lv_obj_align(label_date, LV_ALIGN_TOP_RIGHT, 0, 0);

    // wifi标签
    label_wifi_icon = lv_label_create(obj_main_page);
    lv_label_set_text(label_wifi_icon, LV_SYMBOL_WIFI);
    lv_obj_set_style_text_font(label_wifi_icon, &font_awesome, 0);
    lv_obj_align_to(label_wifi_icon, label_date, LV_ALIGN_OUT_LEFT_MID, -20, 0);

    // 显示上分割线
    lv_obj_t *line_above = lv_line_create(obj_main_page);
    static lv_point_t line_above_points[] = {{0 , 30}, {297, 30}};
    lv_line_set_points(line_above, line_above_points, 2);
    lv_obj_set_style_line_width(line_above, 3, LV_PART_MAIN);
    lv_obj_set_style_line_color(line_above, lv_color_hex(0x2196F3), 0);

    // 天气图标标签
    label_weather_icon = lv_label_create(obj_main_page);
    lv_obj_set_style_text_font(label_weather_icon, &font_qweather, 0);
    lv_obj_set_pos(label_weather_icon, 0, 40);
    lv_qweather_icon_show(st_qweather_data.now_icon);

    // 空气质量等级标签
    obj_qair_level = lv_obj_create(obj_main_page);
    lv_obj_set_style_radius(obj_qair_level, 10, 0);
    lv_obj_set_style_opa(obj_qair_level, LV_OPA_COVER , 0);
    lv_obj_set_style_bg_color(obj_qair_level, lv_palette_main(LV_PALETTE_GREEN), 0);
    lv_obj_set_style_text_color(obj_qair_level, lv_color_hex(0xffffff), 0);
    lv_obj_set_style_border_width(obj_qair_level, 0, 0);
    lv_obj_set_style_pad_all(obj_qair_level, 0, 0);
    lv_obj_set_width(obj_qair_level, 50);  // 设置宽
    lv_obj_set_height(obj_qair_level, 26); // 设置高
    lv_obj_align_to(obj_qair_level, label_weather_icon, LV_ALIGN_OUT_RIGHT_TOP, 5 , 0);

    label_qair_level = lv_label_create(obj_qair_level);
    lv_obj_set_style_text_font(label_qair_level, &font_alipuhui20, 0);
    lv_obj_center(label_qair_level);
    lv_qair_level_show(st_qweather_data.air_quality_level);
 
    // 天气温度标签
    label_weather_temp = lv_label_create(obj_main_page);
    lv_label_set_text_fmt(label_weather_temp, "%d~%d℃", st_qweather_data.daily_temp_min, st_qweather_data.daily_temp_max);
    lv_obj_set_style_text_font(label_weather_temp, &font_alipuhui20, 0);
    lv_obj_align_to(label_weather_temp, label_weather_icon, LV_ALIGN_OUT_RIGHT_MID, 5, 5);

    // 天气文本描述标签
    label_weather_text = lv_label_create(obj_main_page);
    lv_label_set_long_mode(label_weather_text, LV_LABEL_LONG_SCROLL_CIRCULAR);
    lv_obj_set_width(label_weather_text, 80);
    lv_obj_set_style_text_font(label_weather_text, &font_alipuhui20, 0);
    lv_obj_align_to(label_weather_text, label_weather_icon, LV_ALIGN_OUT_RIGHT_BOTTOM, 5, 0);
    lv_label_set_text_fmt(label_weather_text, "%s", qwnow_text);

    // 时间标签
    label_time = lv_label_create(obj_main_page);
    lv_label_set_text_fmt(label_time, "%02d:%02d:%02d", timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec);
    lv_obj_set_style_text_font(label_time, &font_led, 0);
    lv_obj_set_pos(label_time, 142, 42);

    // 星期标签
    label_week = lv_label_create(obj_main_page);
    lv_week_show();
    lv_obj_set_style_text_font(label_week, &font_alipuhui20, 0);
    lv_obj_align_to(label_week, label_time, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, 6); //-25,6


    // 日出日落标签
    label_sun = lv_label_create(obj_main_page);
    lv_label_set_text_fmt(label_sun, "日出 %s", st_qweather_data.daily_sun_rise);
    lv_obj_set_style_text_font(label_sun, &font_alipuhui20, 0);
    lv_obj_set_pos(label_sun, 200, 103);

    // 显示下分割线
    lv_obj_t *below_bar = lv_bar_create(obj_main_page);
    lv_obj_set_size(below_bar, 300, 3);
    lv_obj_set_pos(below_bar, 0, 130);
    lv_bar_set_value(below_bar, 100, LV_ANIM_OFF);

    // 室外对象
    lv_obj_t *obj_out_door = lv_obj_create(obj_main_page);
    lv_obj_set_size(obj_out_door, 100, 80);
    lv_obj_align(obj_out_door, LV_ALIGN_BOTTOM_LEFT, 0, 0);
    lv_obj_set_style_bg_color(obj_out_door, lv_color_hex(0xd8b010), 0);
    lv_obj_set_style_text_color(obj_out_door, lv_color_hex(0xffffff), 0);
    lv_obj_set_style_radius(obj_out_door, 10, 0);
    lv_obj_set_style_border_width(obj_out_door, 0, 0);
    lv_obj_set_style_pad_all(obj_out_door, 5, 0);
    lv_obj_clear_flag(obj_out_door, LV_OBJ_FLAG_SCROLLABLE);

    // 室外标签
    lv_obj_t *label_out_door = lv_label_create(obj_out_door);
    lv_label_set_text(label_out_door, "室外");
    lv_obj_set_style_text_font(label_out_door, &font_alipuhui20, 0);
    lv_obj_align(label_out_door, LV_ALIGN_TOP_MID, 0, 0);

    // 室外温度图标
    lv_obj_t *label_out_door_temp_symbol = lv_label_create(obj_out_door);
    lv_label_set_text(label_out_door_temp_symbol, "\xEF\x8B\x88");
    lv_obj_set_style_text_font(label_out_door_temp_symbol, &font_awesome, 0);
    lv_obj_align(label_out_door_temp_symbol, LV_ALIGN_LEFT_MID, 10, 0);

    // 室外温度
    label_out_door_temp = lv_label_create(obj_out_door);
    lv_label_set_text_fmt(label_out_door_temp, "%02d℃", st_qweather_data.now_temp);
    lv_obj_set_style_text_font(label_out_door_temp, &font_alipuhui20, 0);
    lv_obj_align_to(label_out_door_temp, label_out_door_temp_symbol, LV_ALIGN_OUT_RIGHT_MID, 10, 0);

    // 室外湿度图标
    lv_obj_t *label_out_door_humi_symbol = lv_label_create(obj_out_door);
    lv_obj_set_style_text_font(label_out_door_humi_symbol, &font_awesome, 0);
    lv_label_set_text(label_out_door_humi_symbol, "\xEF\x81\x83");
    lv_obj_align(label_out_door_humi_symbol, LV_ALIGN_BOTTOM_LEFT, 10, 0);
   
    // 室外湿度
    label_out_door_humi = lv_label_create(obj_out_door);
    lv_label_set_text_fmt(label_out_door_humi, "%d%%", st_qweather_data.now_humi);
    lv_obj_set_style_text_font(label_out_door_humi, &font_alipuhui20, 0);
    lv_obj_align_to(label_out_door_humi, label_out_door_humi_symbol, LV_ALIGN_OUT_RIGHT_MID, 10, 0);

    // 室内对象
    lv_obj_t *obj_in_door = lv_obj_create(obj_main_page);
    lv_obj_set_size(obj_in_door, 100, 80);
    lv_obj_align(obj_in_door, LV_ALIGN_BOTTOM_MID, 10, 0);
    lv_obj_set_style_bg_color(obj_in_door, lv_color_hex(0xfe6464), 0);
    lv_obj_set_style_text_color(obj_in_door, lv_color_hex(0xffffff), 0);
    lv_obj_set_style_radius(obj_in_door, 10, 0);
    lv_obj_set_style_border_width(obj_in_door, 0, 0);
    lv_obj_set_style_pad_all(obj_in_door, 5, 0);
    lv_obj_clear_flag(obj_in_door, LV_OBJ_FLAG_SCROLLABLE);

    // 室内标签
    lv_obj_t *label_in_door = lv_label_create(obj_in_door);
    lv_label_set_text(label_in_door, "室内");
    lv_obj_set_style_text_font(label_in_door, &font_alipuhui20, 0);
    lv_obj_align(label_in_door, LV_ALIGN_TOP_MID, 0, 0);

    // 室内温度图标
    lv_obj_t *label_in_door_temp_symbol = lv_label_create(obj_in_door);
    lv_label_set_text(label_in_door_temp_symbol, "\xEF\x8B\x88");
    lv_obj_set_style_text_font(label_in_door_temp_symbol, &font_awesome, 0);
    lv_obj_align(label_in_door_temp_symbol, LV_ALIGN_LEFT_MID, 10, 0);

    // 室内温度
    label_in_door_temp = lv_label_create(obj_in_door);
    lv_label_set_text_fmt(label_in_door_temp, "%02d℃", temp_value);
    lv_obj_set_style_text_font(label_in_door_temp, &font_alipuhui20, 0);
    lv_obj_align_to(label_in_door_temp, label_in_door_temp_symbol, LV_ALIGN_OUT_RIGHT_MID, 10, 0);

    // 室内湿度图标
    lv_obj_t *label_in_door_humi_symbol = lv_label_create(obj_in_door);
    lv_obj_set_style_text_font(label_in_door_humi_symbol, &font_awesome, 0);
    lv_label_set_text(label_in_door_humi_symbol, "\xEF\x81\x83");
    lv_obj_align(label_in_door_humi_symbol, LV_ALIGN_BOTTOM_LEFT, 10, 0);
   
    // 室内湿度
    label_in_door_humi = lv_label_create(obj_in_door);
    lv_label_set_text_fmt(label_in_door_humi, "%d%%", humi_value);
    lv_obj_set_style_text_font(label_in_door_humi, &font_alipuhui20, 0);
    lv_obj_align_to(label_in_door_humi, label_in_door_humi_symbol, LV_ALIGN_OUT_RIGHT_MID, 10, 0);

    //太空人GIF图片
    gif_taikong = lv_gif_create(obj_main_page);
    lv_gif_set_src(gif_taikong, &image_taikong);
    lv_obj_align(gif_taikong, LV_ALIGN_BOTTOM_RIGHT, 0, 0);

    lvgl_port_unlock();
}
